<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Administrator
 * Date: 12-7-15
 * Time: 上午10:42
 * To change this template use File | Settings | File Templates.
 */
include("conn.php");
if (!empty($_POST["sub"])) {
    $sql=sprintf("INSERT INTO `news` (`title`, `dates`, `content`) VALUES ('%s', %s, '%s')",$_POST['title'],'now()',$_POST['content']);
    $query=mysql_query($sql);
    echo "添加成功！";
}

?>
<form action="add.php" method="post">
    <p>
        <label for="title">标题</label>
        <input type="text" name="title" id="title">
    </p>

    <p>
        <label for="content">内容</label>
        <textarea name="content" id="content" cols="30" rows="10"></textarea>
    </p>

    <p>
        <!--        <input type="submit" value="submit" name="sub">-->
        <button name="sub" type="submit" value="sub">Submit</button>
    </p>
</form>